//
//  AIDetailTopTableViewCell.swift
//  AIImage
//
//  Created by deng on 2023/12/10.
//

import UIKit
import Reusable
import SnapKit

class AIDetailTopTableViewCell: UITableViewCell,Reusable {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupViews()
    }
    
    let nameL = UILabel.init()
    let imgV = UIImageView.init()
    
    private func setupViews() {
        
        selectionStyle = .none
        backgroundColor = .clear
        
        nameL.font = .systemFont(ofSize: 30, weight: .semibold)
        nameL.textColor = .white
        contentView.addSubview(nameL)
        nameL.snp.makeConstraints { make in
            make.left.equalTo(20*DS.s)
            make.right.equalTo(-20*DS.s)
            make.top.equalTo(2*DS.s)
        }
        
        contentView.addSubview(imgV)
        imgV.snp.makeConstraints { make in
            make.left.right.equalTo(nameL)
            make.top.equalTo(nameL.snp.bottom).offset(30*DS.s)
            make.height.equalTo((KScreenWidth-40*DS.s)/354*208)
            make.bottom.equalToSuperview().offset(-15*DS.s)
        }
        imgV.contentMode = .scaleAspectFill
        imgV.layer.cornerRadius = 10
        imgV.layer.masksToBounds = true
        
    }
    
    func setUpData(vo:AISaveModel){
        
        nameL.text = vo.name ?? ""
        imgV.image = LocalMan.shared.getImage(imagePath: vo.imagePath ?? "")
    }
}
